<template>
  <div class="lix-container lix-mbr__bg">
    <div class="lix-mbr__header">
      <div class="lix-mbr__avatar">
        <open-data type="userAvatarUrl"></open-data>
        <!-- <image src="../../static/image/24.png"/> -->
      </div>
      <div class="lix-mbr__info" @click="go2UserInfoPage">
        <div class="lix-mbr__info--content">
          <open-data type="userNickName"></open-data>
          <!-- <div>Originalee</div> -->
          <div class="desc"></div>
        </div>
        <navigator url="#">
          <!-- <image src="../../static/image/arrow_down.png"/> -->
        </navigator>
      </div>
    </div>
    <div class="lix-mbr__content">
      <div class="lix-mbr__item" v-for="(item, idx) in mainData" :key="idx">
        <navigator :url="item.url">
          <image :src="item.src" />
          <div>{{ item.key }}</div>
        </navigator>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      mainData: [
        {id: 1, key: '我的订单', src: '../../static/images/order.png', url: '/pages/member/myhistory'},
        {id: 2, key: '关于', src: '../../static/images/about.png', url: '/pages/member/myclass'}
      ]
    };
  },
  onLoad() {
    this.checkAuth();
  },
  methods: {
    go2UserInfoPage(e) {
      wx.navigateTo({
        url: '/pages/member/userinfo'
      });
    },
    // 检查授权页面 弹出授权窗口
    checkAuth() {
      // 查看是否授权
      wx.getSetting({
        success(res) {
          if (res.authSetting['scope.userInfo']) {
            console.log('已经授权');
            // 已经授权，可以直接调用 getUserInfo 获取头像昵称
            wx.getUserInfo({
              success: function(res) {
                console.log(res.userInfo);
              }
            });
          } else {
            console.log('没有授权');
            wx.navigateTo({
              url: '/pages/member/auth'
            });
          }
        }
      });
    }
  }
};
</script>

<style lang="scss">
@import "../../theme-chalk/member.scss";
</style>
